package cn.itcast.com.homework.day84;

public class Num{
    int begin = 0;
    public synchronized void add1() throws InterruptedException {
        if (begin%2==0){
            this.wait();
        }else {
            System.out.println(Thread.currentThread().getName()+ "做了"+ begin);
            this.begin = this.begin + 1;
            //this.food = newfood;
            this.notify();
        }
    }
    public synchronized void add2() throws InterruptedException {
        if (begin%2!=0){
            this.wait();
        }else {

            System.out.println(Thread.currentThread().getName()+ "做了"+ begin);
            this.begin = this.begin + 1;
            //this.food = newfood;
            this.notify();
        }
    }
    public boolean ninenine(){
        return begin<=99;
    }

}
